package com.sc.nft.admin.controller;

import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.dto.IdRequest;
import com.sc.nft.feign.WxMiniThemeActivityClient;
import com.sc.nft.req.activity.ThemeActivityGoodsReq;
import com.sc.nft.req.activity.ThemeActivityListReq;
import com.sc.nft.req.activity.ThemeActivityPageReq;
import com.sc.nft.req.activity.ThemeActivityReq;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import com.sc.nft.vo.activity.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/wxMiniMall/activity")
@Api(tags = "主题活动")
public class WxMiniThemeActivityController {

    private final WxMiniThemeActivityClient wxMiniThemeActivityClient;

    /**
     * 创建主题活动
     * @param request
     * @return
     */
    @PostMapping(value = "/create", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "创建主题活动")
    @SysMemberLogin
    public Result createThemeActivity(@Valid @RequestBody ThemeActivityReq request){
        return wxMiniThemeActivityClient.createThemeActivity(request);

    }

    /**
     * 编辑主题活动
     * @param request
     * @return
     */
    @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "编辑主题活动")
    @SysMemberLogin
    public Result updateThemeActivity(@Valid @RequestBody ThemeActivityReq request) {
        return wxMiniThemeActivityClient.updateThemeActivity(request);

    }

    /**
     * 主题活动详情
     * @param idRequest
     * @return
     */
    @PostMapping(value = "/details", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "主题活动详情")
    @SysMemberLogin
    public Result<ThemeDetailsVO> details(@Valid @RequestBody IdRequest idRequest) {
        return wxMiniThemeActivityClient.details(idRequest);
    }

    /**
     * 主题活动详情
     * @param request
     * @return
     */
    @PostMapping(value = "/goodsDetails", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "主题活动商品详情")
    @SysMemberLogin
    public Result<List<ThemeItemDetailsVO>> goodsDetails(@Valid @RequestBody ThemeActivityGoodsReq request) {
        return wxMiniThemeActivityClient.goodsDetails(request);
    }

    /**
     * 主题活动列表
     * @param request
     * @return
     */
    @PostMapping(value = "/admin/page", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "主题活动列表")
    @SysMemberLogin
    public PageResult<ThemeActivityPageVO> adminPage(@RequestBody ThemeActivityPageReq request) {
        return wxMiniThemeActivityClient.adminPage(request);
    }



    /**
     * 选择主题活动
     * @param request
     * @return
     */
    @PostMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "选择主题活动")
    @SysMemberLogin
    public Result<List<ThemeActivityPageVO>> adminList(@RequestBody ThemeActivityListReq request) {
        return wxMiniThemeActivityClient.adminList(request);
    }



    /**
     * 删除主题活动
     * @param request
     * @return
     */
    @PostMapping(value = "/remove", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "删除")
    public Result remove(@RequestBody IdRequest request) {
        return wxMiniThemeActivityClient.remove(request);
    }

}